package Q2;

import javax.persistence.*;
import java.sql.Date;
import java.util.Arrays;

/**
 * 学生实体类
 *
 * @author chisheng
 * @since 2021-10-25
 */
@Entity  /* 标识为实体类 */
@Table(name = "Student")  /* 设置关联的表名 */
public class JpaStudent {

    /**
     * 学生 id
     */
    @Id  /* 通过 @Id 标识主键 */
    private Integer id;

    /**
     * 学生学号
     */
    @Column(name = "no")  /* 通过 @Column 标识属性 */
    private String no;

    /**
     * 学生姓名
     */
    private String name;

    /**
     * 学生年龄
     */
    private Integer age;

    /**
     * 学生出生日期
     */
    private Date birthday;

    /**
     * 学生半身照图片
     */
    private byte[] photo;

    /**
     * 无参构造
     */
    public JpaStudent() {
    }

    /**
     * 满参构造
     *
     * @param id       学生 id
     * @param no       学生学号
     * @param name     学生姓名
     * @param age      学生年龄
     * @param birthday 学生出生日期
     * @param photo    学生半身照图片
     */
    public JpaStudent(Integer id, String no, String name, Integer age, Date birthday, byte[] photo) {
        this.id = id;
        this.no = no;
        this.name = name;
        this.age = age;
        this.birthday = birthday;
        this.photo = photo;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public byte[] getPhoto() {
        return photo;
    }

    public void setPhoto(byte[] photo) {
        this.photo = photo;
    }

    @Override
    public String toString() {
        return "JpaStudent{" +
                "id=" + id +
                ", no='" + no + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", birthday=" + birthday +
                ", photo=" + Arrays.toString(photo) +
                '}';
    }

}
